//
//  DetailActivityViewController.m
//  小汽车
//
//  Created by 杜远洋 on 14-12-29.
//  Copyright (c) 2014年 蓝欧科技. All rights reserved.
//

#import "DetailActivityViewController.h"
#import "CarActivityBase.h"
#import "ActivityModel.h"
@interface DetailActivityViewController ()<UIWebViewDelegate>


@end

@implementation DetailActivityViewController

- (void)dealloc
{
    [_event_link release];
    [super dealloc];
}

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self createWebView];
    UIImage *image = [UIImage imageNamed:@"collection"];
    UIImage *newImage = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:newImage style:UIBarButtonItemStylePlain target:self action:@selector(collectionAction:)];
}
-(void)createWebView
{
    UIWebView * webView = [[UIWebView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    webView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
    webView.delegate = self;
    [webView setScalesPageToFit:YES];
    webView.backgroundColor = [UIColor whiteColor];
    NSURL *url = [NSURL URLWithString:self.event_link];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [webView loadRequest:request];
    [self.view addSubview: webView];
    [webView release];
}

#warning 收藏事件
-(void)collectionAction:(UIButton *)button
{
    //数据库的收藏
    ActivityModel *model = [ActivityModel activityWithEvent_title:self.event_title event_link:_event_link];
    NSString *str = [CarActivityBase insertIntoCarActivity:model];
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:str delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
    [alert show];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
